using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "NewRangedWeapon", menuName = "Weapons/Ranged Weapon", order = 3)]
public class RangedWeapon : Weapon
{
    public Projectile projectilePrefab;
    public float projectileSpeed = 20f;
    public float spreadAngle = 5f;

    protected override void PerformAttack()
    {
        Debug.Log("Performing ranged attack");
        // Add random spread
        Quaternion spread = Quaternion.Euler(
            Random.Range(-spreadAngle, spreadAngle),
            Random.Range(-spreadAngle, spreadAngle),
            0
        );

        // Create projectile
        Projectile projectile = Instantiate(
            projectilePrefab,
            firePoint.position,
            firePoint.rotation * spread
        );

        // Set projectile properties
        projectile.Initialize(damage, projectileSpeed);

        // Play sound and effects
        EventManager.TriggerEvent(new RangedAttackFiredEvent(this));
    }
}